﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Timesheet.WebForm.TimeSheets.Default" %>

<%@ Register Assembly="DevExpress.Web.v14.2, Version=14.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    
    <asp:Table runat="server">
        <asp:TableRow>
            <asp:TableCell Width="160px">
                <dx:ASPxLabel Font-Size="22px" Font-Names="Calibri"  Font-Bold="true" ForeColor="#4A72A3" runat="server" Text="Project name" CssClass="maintitle"></dx:ASPxLabel>            
            </asp:TableCell>
            <asp:TableCell Width="250px">
                <dx:ASPxComboBox ID="cbxPrj" Width="95%" runat="server" DataSourceID="dsOwnerProjects" TextField="ProjectName" ValueField="PrjID" DropDownRows="8">
                </dx:ASPxComboBox>
            </asp:TableCell>
            <asp:TableCell Width="80px">
                <asp:Button ID="btnSearch" runat="server" Font-Bold="True" Font-Overline="False" Text="Search" OnClick="btnSearch_Click" />
            </asp:TableCell>
            <asp:TableCell Width="60px">
                <asp:Button ID="btnNew" runat="server" Font-Bold="True" Font-Overline="False" Text="New" OnClick="btnNew_Click" />
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>
   
    <div class="title">
        <dx:ASPxLabel ID="ASPxLabel8" CssClass="maintitle" runat="server" Text="TimeSheets" Font-Size="22px" Font-Bold="true" ForeColor="#4A72A3"></dx:ASPxLabel>
    </div>
    <div class="detail1">
        <dx:ASPxGridView
            ID="grvTimeSheets"
            runat="server"
            EnableTheming="True"
            Theme="Office2010Silver"
            SettingsPager-PageSize="15"
            Width="1050px"
            DataSourceID="dsTimeSheets"
            AutoGenerateColumns="False"
            KeyFieldName="Id"
            OnRowInserting="grvTimeSheets_RowInserting" Border="0px" OnCommandButtonInitialize="grvTimeSheets_CommandButtonInitialize" OnCellEditorInitialize="grvTimeSheets_CellEditorInitialize" OnCustomErrorText="grvTimeSheets_CustomErrorText">

            <Columns>
                <dx:GridViewDataTextColumn FieldName="Id" VisibleIndex="0" ReadOnly="true" Visible="false">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataComboBoxColumn ReadOnly="true" FieldName="ProjectID" Name="ProjectID" Caption="Project" VisibleIndex="1" Width="340px">
                    <PropertiesComboBox DataSourceID="dsOwnerProjects" TextField="ProjectName" ValueField="PrjID">
                        <Columns>
                            <dx:ListBoxColumn Caption="PrjID" FieldName="PrjID" Name="PrjID" Visible="false" />
                            <dx:ListBoxColumn Caption="Project Name" FieldName="ProjectName" Name="ProjectName" />
                        </Columns>
                    </PropertiesComboBox>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="Team" FieldName="TeamID" Name="TeamID" VisibleIndex="2" Width="200px">
                    <PropertiesComboBox DataSourceID="dsTeams" TextField="TeamName" ValueField="Id">
                        <Columns>
                            <dx:ListBoxColumn Caption="Id" FieldName="Id" Name="Id" Visible="False" />
                            <dx:ListBoxColumn Caption="Team Name" FieldName="TeamName" Name="TeamName" />
                        </Columns>
                    </PropertiesComboBox>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataTextColumn FieldName="Week" ReadOnly="true" Visible="True" VisibleIndex="3" UnboundType="String" Name="Week" Width="180px">
                    <DataItemTemplate>
                        <a target="_self" href="Lines.aspx?tmshID=<%# Container.KeyValue%>"><%# Eval("Week").ToString()%></a>
                    </DataItemTemplate>
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataComboBoxColumn Caption="Status" Name="Status" FieldName="Status" VisibleIndex="6" Width="140px">
                    <PropertiesComboBox>
                        <Items>
                            <dx:ListEditItem Text="Open" Value="0" />
                            <dx:ListEditItem Text="Coodinator pending" Value="1" />
                            <dx:ListEditItem Text="Manager pending" Value="2" />
                            <dx:ListEditItem Text="Closed" Value="3" />
                        </Items>
                    </PropertiesComboBox>
                </dx:GridViewDataComboBoxColumn>

                <dx:GridViewCommandColumn Name="colAction" Caption="Action" VisibleIndex="7" Width="130px" ShowDeleteButton="true" ShowEditButton="true">
                </dx:GridViewCommandColumn>


            </Columns>

            <SettingsBehavior ColumnResizeMode="Disabled" ConfirmDelete="true" AllowFocusedRow="true" AllowSelectByRowClick="true" />
            <SettingsPager PageSize="15"></SettingsPager>
            <SettingsEditing Mode="Inline">
            </SettingsEditing>
            <Settings HorizontalScrollBarMode="Hidden" />

            <SettingsCommandButton>
                <UpdateButton ButtonType="Button">
                </UpdateButton>
                <CancelButton ButtonType="Button">
                </CancelButton>
                <DeleteButton ButtonType="Button">
                </DeleteButton>
                <EditButton ButtonType="Button">
                </EditButton>
            </SettingsCommandButton>
            <Styles>
                <Header HorizontalAlign="Center" Font-Size="Small">
                </Header>
                <AlternatingRow BackColor="#EDF5FF" Enabled="True">
                </AlternatingRow>
                <SelectedRow BackColor="#99CCFF">
                </SelectedRow>
                <FocusedRow BackColor="#99CCFF">
                </FocusedRow>
                <Row Font-Size="11pt" Font-Names="Calibri">
                </Row>
            </Styles>
        </dx:ASPxGridView>

        <asp:ObjectDataSource ID="dsTimeSheets" runat="server"
            DataObjectTypeName="Timesheet.Domain.TimeSheets"
            DeleteMethod="Delete"
            InsertMethod="Add"
            SelectMethod="GetTimeSheets"
            TypeName="Timesheet.Service.ITimeSheetsService"
            UpdateMethod="SimpleUpdate"
            OnObjectCreating="ds_ObjectCreating">
            <SelectParameters>
                <asp:SessionParameter DefaultValue="-1" Name="userId" SessionField="UserId" DbType="String" />
                <asp:SessionParameter DefaultValue="0" Name="role" SessionField="userrole" DbType="String" />
                <asp:QueryStringParameter DefaultValue="-1" Name="prjID" QueryStringField="prjID" Type="Int64" />
            </SelectParameters>
        </asp:ObjectDataSource>

      
        <asp:ObjectDataSource
            ID="dsOwnerProjects"
            runat="server"
            DataObjectTypeName="Timesheet.Domain.Project"
            SelectMethod="GetActivedRefProjects"
            TypeName="Timesheet.Service.IProjectService"
            OnObjectCreating="dsPrjects_ObjectCreating">
            <SelectParameters>
                <asp:SessionParameter DefaultValue="-1" Name="userID" SessionField="UserId" DbType="Int64" />
            </SelectParameters>
        </asp:ObjectDataSource>

        <asp:ObjectDataSource
            ID="dsTeams"
            runat="server"
            DataObjectTypeName="Timesheet.Domain.Team"
            SelectMethod="GetTeams"
            TypeName="Timesheet.Service.ITeamService"
            OnObjectCreating="dsTeams_ObjectCreating">
         </asp:ObjectDataSource>
    </div>

</asp:Content>

